package android.aspectjdemo;

import android.util.Log;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;

/**
 * Created by xin on 2018/12/26.
 * 功能描述：打印acitivty的生命周期方法
 */
@Aspect
public class LogLifeCycle {
    public void log(String s) {
        Log.w("LogActivityLife", s);
    }

    @Before("execution(* android.app.Activity.*(..))")
//    @Before("call(* android.aspectjdemo.BaseActivity.*(..))")
    public void activityLogLife(JoinPoint joinPoint) {
        log("activityLogLife() called with: joinPoint = [" + joinPoint + "]");
    }

    @Before("execution(* android.aspectjdemo.MainActivity.onViewClick(..))")
//    @Before("call(* android.aspectjdemo.MainActivity.onViewClick(..))") //是不会执行的捕获到的
    public void activityMainLogLife(JoinPoint joinPoint) {
        log("activityMainLogLife() called with: joinPoint = [" + joinPoint + "]");
    }

}
